﻿@{
    ViewBag.Title = "Home Page";
}

<div class="jumbotron">
    <h1>MVC5 + Onion Architecture + BDD with Specflow</h1>
    <p class="lead">An MVC5 application with Web API to showcase BDD using specflow where solution architecture is Onion Architecture.</p>
    <p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>

<div class="row">
    <div class="col-md-12">
        <h2>Active Employees</h2>
        <table id="tblEmployees" class="table table-bordered">
            <tbody>
                <tr>
                    <th>Employee Id</th>
                    <th>First Name</th>
                    <th>Last Name</th>
                </tr>
            </tbody>
        </table>
    </div>
</div>

@section scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            var activeEmployeesUrl = 'http://localhost:49829/api/employee';
            $.get(activeEmployeesUrl, '', function (data, x, xhr) {
                if(data.length > 0)
                {
                    var table = $('#tblEmployees');
                    for(var i=0; i<data.length; i++)
                    {
                        $('#tblEmployees > tbody:last').append('<tr><td>' + data[i].EmployeeId + '</td><td>' + data[i].FirstName + '</td><td>' + data[i].LastName  + '</td></tr>');
                    }
                }
            },null);
        });
    </script>
}